<template>
    <div class="header">
        <div class="l-content">
            <el-icon color="white" size="20" class="icons">
                <ArrowLeft />
            </el-icon>
        </div>
        <div class="c-content">
            {{headerStore.state.name}}
        </div>
        <div class="r-content">
            <el-dropdown>
                <span class="el-dropdown-link">
                    <img :src="getImageUrl('user')" class="user" />
                </span>
                <template #dropdown>
                    <el-dropdown-menu>
                        <el-dropdown-item>个人信息</el-dropdown-item>
                        <el-dropdown-item>退出</el-dropdown-item>
                    </el-dropdown-menu>
                </template>
            </el-dropdown>
        </div>
    </div>

</template>

<script setup>
import { ref, computed } from "vue"
import { useHeaderStore } from "../stores/header"

// import.meta.url是当前文件的路径
const getImageUrl = (user) => {
    return new URL(`../assets/images/${user}.png`, import.meta.url).href
}

const headerStore = useHeaderStore();

</script>

<style lang="less" scoped>
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
}

.l-content {
    .el-button {
        margin-right: 20px;
    }
}

.c-content {
    text-align: center;
    flex-grow: 1;
    color: white;
}

.r-content {
    .user {
        width: 40px;
        height: 40px;
        border-radius: 5px;
    }
}
</style>